package Year22_Month07.day06;

import java.util.Arrays;

public class K次取反后最大化的数组和 {
    public int largestSumAfterKNegations(int[] nums, int k) {
        int sum = 0;
        while(k-- > 0){
            Arrays.sort(nums);
            nums[0] = -nums[0];
        }
        for (int i:nums){
            sum += i;
        }
        return sum;
    }
}
